perm filename ELEPHA[W79,JMC] blob sn#423307 filedate 1979-03-04 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	.require "memo.pub[let,jmc]" source
C00006 00003		%2prec(P1,P2,h) ← not qn h and not P2 qa h and (P1 qa h:
C00007 ENDMK
C⊗;
.require "memo.pub[let,jmc]" source
.cb THE PROGRAMMING LANGUAGE ELEPHANT


	The programming language Elephant (it never forgets)
is a sequential language (i.e. based on assignments).
Its statements may refer to the past of the computation.
For the time being, consider it as an extension to the Lisp program
feature.  Thus statements may refer to

.item←0
	#. x = 3 more recently than y = 9

	#. the value of x the last time y = 3

	Such things can be accomplished by adding to
a simple sequential language a reserved identifier called %2history%1.
Programs can refer to %2history%1 but cannot assign to it.
%2history%1 is a record of all assignments that have been made, i.e. it
is a list of pairs (<variable>.<value>), and it is updated every time
an assignment is made.  The update is made by %2cons%1ing latest
variable-value pair on the front of %2history%1.  Thus the statement

	%2x ← 3%8x%2 + y;%1

would be equivalent to the pair of statements

	%2x ← 3%8x%2 + y; history ← [X . x] . history%1;

in program feature Lisp.

	A good compiler for Elephant will not generate machine code that
maintains an actual %2history%1 variable, because its use would fill up
storage rapidly and searching it would take excessive time.  Instead the
compiler will cleverly decide what information must actually be kept and
generate code that refers to additional variables, arrays, trees and lists
as convenient and required in order to execute the Elephant program.  How
much cleverness is required and whether the modes of reference to the past
have to be restricted or whether the compiler has to be helped remain to
be seen.

	It looks as though one might be able to eliminate assignments
entirely by referring to ⊗history in ever more complex ways.  However,
these more complex ways would involve recursively defined functions,
and variables would creep back in as arguments to these functions.
Moreover, this would probably place excessive burdens on the intelligence
of the compiler which is required to determine what historical
information actually must be preserved.  Therefore we will let variables
and arrays and will merely try to see what is the most natural and
convenient way of writing.  If ⊗history is never referred to, then
Elephant will have turned into a mouse.

	Let us give a simple program in Elephant.

	%2prec(P1,P2,h) ← not qn h and not P2 qa h and (P1 qa h:
or prec(P1,P2,qd h)%1